<?php 
global $options;
foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
$dateformat = get_option('date_format');
$timeformat = get_option('time_format');
$layout = get_post_meta($post->ID, 'template', true);
get_header(); ?>


  <div id="content">
    <div class="wrap">
    
      <div class="sep sepinside">&nbsp;</div>
    
      <?php wp_reset_query(); 
      if (have_posts()) : while (have_posts()) : the_post(); ?>
		
      <?php if ($layout != 'full') { ?>
      <div class="column column-narrow">
      
        <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar: Posts (Left)') ) : ?>&nbsp;<?php endif; ?>
        
      </div><!-- end .column-narrow -->
      <?php } ?>
      
      <div class="column <?php if ($layout == 'double') {echo"column-double column-last ";} if ($layout == 'full') {echo"column-full column-last ";} ?>column-double column-last column-content single">
		<h1>
			<?php 
				$contactInfo = get_group('Contact Details'); // use the Custom Group name
				if (!is_null($contactInfo)) {
					foreach($contactInfo as $info) {
						if ($info['contact_details_employee_or_affiliate'][1] == "Employee" ) { echo $info['contact_details_salutation'][1]." "; }
					}
				}
				the_title();
				if ($info['contact_details_administrative_employee'][1] == 1 ) { echo " <em class='admin-staff'>Administrative Staff Member</em>"; }
			?>
		</h1>
		
		<?php
			foreach((get_the_category()) as $childcat) {
				$parentcat = $childcat->category_parent;
				//echo get_cat_name($parentcat);
			}
			//echo get_category_parents($cat, false, '');
			if(get_cat_name($parentcat) == 'News') { ?>
				<p class="postmetadata"><?php the_time("$dateformat") ?></p>
		<?php } ?>
		
		
		<?php 
			// IHRC Courses
			$courseInformation = get_group('Course Details'); // use the Custom Group name
			if (!is_null($courseInformation)) {
				foreach($courseInformation as $courseInfo) {
					if ($courseInfo['course_detail_link_to_syllabus'][1] != '') {
						echo "<p><strong>Reference Number:</strong> <a href='".$courseInfo['course_detail_link_to_syllabus'][1]."' target='_blank'>".$courseInfo['course_detail_subject'][1]." ".$courseInfo['course_detail_course_id'][1]."</a>";
					}
					else {
						echo "<p><strong>Reference Number:</strong> ".$courseInfo['course_detail_subject'][1]." ".$courseInfo['course_detail_course_id'][1];
					}
				}
			}
		?>
		
		<?php 
			// IHRC Workshops
			$days = '';
			$special_course = get_group('Workshop Details'); // use the Custom Group name
			if (!is_null($special_course)) {
				foreach( $special_course as $detail ){
					foreach ( $detail as $dates ){
						sort( $dates, SORT_NUMERIC );
						foreach ( $dates as $date ){
							$days .= $date." | ";
						}
					}
				}
				$days = rtrim( $days, ' | ' );
				echo '<p><strong>Date(s):</strong> '.$days.'</p>';
			}
		?>
		
		
		<?php
		
		if (!is_null($contactInfo)) {
			echo "<div class='vcard'>";
				foreach($contactInfo as $info) {
					
					unset($img);
					if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail() ) {
						$attachedFile = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '' );
						$img = $attachedFile[0]; 
					}
					else { 
						if ($proud_cf_use == 'Yes') {
							$img = get_post_meta($post->ID, $proud_cf_photo, true);
						} // if CF used
						else {
							if (!$img) {
								$img = catch_that_image($post->ID);
							}
						} // if CF not used
					}
					if ($img) {?>
						<div class="thumb" style="display: inline; float: left; margin: 0 10px 10px 0;"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?h=120&amp;w=120&amp;zc=1&amp;src=<?php echo $img ?>" alt="<?php the_title(); ?>" class="bordered" /></a></div>
					<?php
						
					}
					
					
					if (strlen($info['contact_details_professional_title'][1]) > 0 ) { echo "<p class='title'><em>".$info['contact_details_professional_title'][1]."</em></p>"; }
					$positionList = get('contact_details_position_title');
					if (!is_null($positionList) && $info['contact_details_employee_or_affiliate'][1] == "Employee" && count($positionList) >= 1) {
						echo "<div class='role'><p><strong>Position(s): </strong>";
						$arrayPos = count($positionList);
						foreach($positionList as $index => $value) {
							echo $value;
							if (($index+1) != $arrayPos) { echo ", "; }
						}
						echo "</p></div>";
						lab_tags();
					}
					if (strlen($info['contact_details_department_center'][1]) > 0 ) {
						echo "<div class='org'>";
						echo $info['contact_details_department_center'][1];
						if (strlen($info['contact_details_room_number'][1]) > 0 ) { echo ", ".$info['contact_details_room_number'][1]; }
						echo "</div>";
					}
					if (strlen($info['contact_details_university_organization'][1]) > 0 ) { echo "<div class='org'>".$info['contact_details_university_organization'][1]."</div>"; }
					if (strlen($info['contact_details_email_address'][1]) > 0 ) { echo "<p class='email'><strong>Email: </strong><a class='email' href='mailto:".$info['contact_details_email_address'][1]."'>".$info['contact_details_email_address'][1]."</a></p>"; }
					if (strlen($info['contact_details_telephone_number'][1]) > 0 ) { echo "<div class='tel'><p><strong>Telephone: </strong><em>".$info['contact_details_telephone_number'][1]."</em></p></div>"; }
					if (strlen($info['contact_details_web_site'][1]) > 0 ) { echo "<p><strong>Web Site URL: </strong><a class='url' href='".$info['contact_details_web_site'][1]."'>".$info['contact_details_web_site'][1]."</a></p>"; }
				}
			echo "</div>";
		}
		?>
		
		<?php
			if (is_null($contactInfo)) {
				lab_tags();
			}
		?>
		
        <?php 
        //if (!is_null($courseInformation)) {
	        the_content('');
	    //}
	    ?>
		
        <?php wp_link_pages(array('before' => '<p class="pages"><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
        
        <p class="postmetadata">By <?php the_author_posts_link(); ?> in <span class="category"><?php the_category(', '); ?></span> <span class="datetime"><?php edit_post_link( __('Edit &raquo;'), ' | ', ''); ?></span></p>
        <?php comments_template(); ?>
      
      </div><!-- end .column-content -->

      <?php if ($layout != 'double' && $layout != 'full') { ?><div class="column column-narrow column-last">
      
        <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar: Posts (Right)') ) : ?>&nbsp;<?php endif; ?>
      
      </div><!-- end .column-narrow -->
      <?php } ?>

<?php endwhile; endif; ?>

      <div class="clear">&nbsp;</div>

    </div><!-- end .wrap -->
  </div><!-- end #content -->

<?php get_footer(); ?>